function init(){
	//初始化默认一级和二级菜单
	initShowDefaultFunc();
	//初始化重要的ip地址
	initIpForPB();
	//初始化素描图数据库信息
	initForSketchInfo();
	//加载地图
	loadMap();
	//地图放大缩小事件的监控
	mapEvtInit();
	//gps功能的注册函数
	initGPSFunction();
	
	
}
/////平板上数据的配置信息  采集素描图用
function initForSketchInfo(){
	//平板的IP
	localIp = "127.0.0.1";
	//平板的数据库端口
	localPort = "1433";
	//平板的数据库用户名
	localDbUsername = "sa";
	//平板的数据库密码
	localDbUserPass = "guest";
	//平板的数据库名称
	localDbName = "platform";
}
function initIpForPB(){
	//快报的3g
	InterFor3G = "http://127.0.0.1:8080/whshservices-goo";
	InterForGuotu = "http://127.0.0.1:8080/whshservices-goo";
	//本机取文件夹图片
	InterForGetImgUrl = "http://127.0.0.1:8080/pbsite";
	//本机的工程名称
	projectName = "pbsite";
}

//初始化默认一级和二级菜单
function initShowDefaultFunc(){
	//一级展示
	$("#bFuncContentDiv").append(bFunctionBarHTML);
	initBfunctionEvent();
	$("#MMenu_1").attr("class","currentFuncDiv");
	//二级展示
	$("#secondContentDiv").append(MMenu_1Html);
	initSfunctionEvent();
	//隐藏二级展示的事件
	$("#secondaryImageDiv").click(function(){
		var currClass = $("#secondaryImageDiv").attr("class");
		if(currClass == "secondaryFuncBarHide"){
			$("#secondaryImageDiv").attr("class","secondaryFuncBarShow");
			$("#secondContentDiv").show();
		}else{
			$("#secondaryImageDiv").attr("class","secondaryFuncBarHide");
			$("#secondContentDiv").hide();
		}
	});
}

//加载地图的函数
function loadMap(){
	//给map赋高度
	//$("#map").css("height",(document.documentElement.clientHeight-150)+"px");
	/*var navigation = new OpenLayers.Control.Navigation();
	map = new OpenLayers.Map('map', {
        maxExtent: new OpenLayers.Bounds(107.9750335, 26.8807595, 116.5193165, 35.4250425),
        maxResolution: 0.0110505078125,
        controls: [navigation]
    });
	layer = new OpenLayers.Layer.ArcGIS93Rest("Hubei",'http://localhost/ArcGIS/rest/services/420000/MapServer/export',{}, { singleTile: true, numZoomLevels: 64,ratio:1 });
    map.addLayer(layer);
    map.zoomToMaxExtent();*/
    //给map赋高度
	var navigation = new OpenLayers.Control.Navigation();
	map = new OpenLayers.Map('map', {
       maxExtent: new OpenLayers.Bounds(109.710799 ,29.864169, 111.815981 ,31.969352),
		// maxExtent: new OpenLayers.Bounds(107.9750335, 26.8807595, 116.5193165, 35.4250425),
        maxResolution: 0.00411168359375,///0.016446734375    0.0082233671875  0.00411168359375
        controls: [navigation]
    });
	var minZoom = 1;//地图最小级别
	var maxZoom = 5//地图最大级别
	/////读取mapgis文件夹格式地图
    var wmts = new OpenLayers.Layer.WMTS({
        name: "WMTS",
        service: "WMTS",
        request:"GetTile",
        url: InterForGetImgUrl+"/GetIMG.jsp", 
        layer: "hbyx", 
        matrixSet: "hbyx", 
		style: "",
		isBaseLayer: true,
    });
    map.addLayer(wmts);
    map.setCenter(new OpenLayers.LonLat(110.8,30.9), minZoom);
    map.events.register('zoomend', this, function (event) {
        var x = map.getZoom();
        
        if( x < minZoom){
            map.zoomTo(minZoom);
        }
        if(x>maxZoom){
        	 map.zoomTo(maxZoom);
        }
    });
}

//地图放大缩小控件的事件
function mapEvtInit(){
	var zoomInControl = new OpenLayers.Control.ZoomBox({map:map});
	zoomInControl.draw();
	map.addControl(zoomInControl);
	var zoomOutControl = new OpenLayers.Control.ZoomBox({map:map,  out: true});
	zoomOutControl.draw();
	map.addControl(zoomOutControl);
	var panControl = new OpenLayers.Control.DragPan({ map: map });
	map.addControl(panControl);
	//放大
	$('#zoomIn').click(function(){
		zoomOutControl.deactivate();
		panControl.deactivate();
		zoomInControl.activate();
	});
	//缩小
	$('#zoomOut').click(function(){
		zoomInControl.deactivate();
		panControl.deactivate();
		zoomOutControl.activate();
	});
	//移动
	$('#pan').click(function(){
		zoomInControl.deactivate();
		zoomOutControl.deactivate();
		panControl.activate();
	});
	//复位
	$('#restore').click(function () {
		//map.zoomToMaxExtent();
		map.setCenter(new OpenLayers.LonLat(12799839.008522447,3551570.0822424218), 6);
	});
}
